package com.mty.cc.service.impl;


import com.mty.cc.mapper.AdminMapper;
import com.mty.cc.po.Admin;
import com.mty.cc.service.AdminService;
import com.mty.cc.util.uuid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;

@Service
public class AdminServiceImpl implements AdminService {

    @Autowired(required=false)
    private AdminMapper adminMapper;

    /*
     * @description: 添加
     * @author: mty
     */
    @Override
    public void add(Admin admin) {
        admin.setId(uuid.getRandomIdByUUID());
        adminMapper.insert(admin);
    }

    /*
     * @description: 按照主键更新
     * @author: mty
     */
    @Override
    public void update(Admin admin) {
        adminMapper.update(admin);
    }

    /*
     * @description: 按照ID删除
     * @author: mty
     */
    @Override
    public void deleteById(String id) {
        adminMapper.deleteById(id);
    }

    /*
     * @description: 查询全部
     * @author: mty
     */
    @Override
    public List<Admin> queryByAll() {
        return adminMapper.queryByAll();
    }

    @Override
    public List<Admin> queryByOne(String username, String password) {
        return adminMapper.queryByOne(username,password);
    }

    /*
     * @description: 根据ID查询
     * @author: mty
     */
    @Override
    public Admin queryById(String id) {
        return adminMapper.queryById(id);
    }
}

